<template>
  <div class="padding-lr40">
    <div>
      <div class="item_left">
        <div class="item_p1">机构类型</div>
        <div class="item_p2">机构类型一旦选择无法修改，请谨慎选择</div>
      </div>
      <div>
        <van-cell @click="show1 = true" :title="type_mame" is-link />
      </div>
    </div>

    <van-popup v-model="show1" position="bottom">
      <van-picker
        show-toolbar
        :columns="types"
        value-key="type_name"
        @confirm="getType"
        @cancel="cancel"
        :default-index="0"
      />
    </van-popup>

    <div class="btn" @click="go">继续</div>
    <div class="btn no" @click="nogo">暂时跳过</div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      types: [], // 全部企业类型
      type_id: "", // 企业类型 id
      type_mame: "",
      show1: false
    };
  },
  mounted() {
    this.$axios
      .post("/home/getEntinfo", {
        token: localStorage.getItem("qx_token")
      })
      .then(res => {
        if (res.data.data.is_perfect == "-1") {
          this.$router.replace({
            name: "mine"
          });
          return false;
        }
      });
    this.getClass();
    document.querySelector("html").style.backgroundColor = "#ffffff";
  },
  methods: {
    cancel() {
      this.show1 = false;
    },
    //   获取类型
    getClass() {
      this.$axios
        .post("/home/organization", {
          token: window.localStorage.getItem("qx_token")
        })
        .then(res => {
          res.data.data.unshift({
            id: 0,
            type_name: "请选择"
          });
          this.types = res.data.data;
          this.type_id = this.types[0].id;
          this.type_mame = this.types[0].type_name;
        });
    },
    // 获取id
    getType(e) {
      this.show1 = false;
      this.type_id = e.id;
      this.type_mame = e.type_name;
    },
    go() {
      if(this.type_id == 0){
        this.$toast('请选择机构类型')
        return false
      }
      this.$router.push({
        path: "/perfectEdit",
        query: {
          type_id: this.type_id,
          type_name: this.type_mame
        }
      });
    },
    nogo() {
      this.$router.push({
        path: "/mine"
      });
    }
  }
};
</script>
<style scoped>
.item_left {
  line-height: 1;
  padding: 20px 0 30px;
}
.item_p1 {
  font-size: 16px;
  color: #2b2b2b;
}
.item_p2 {
  font-size: 14px;
  color: #a6a6a6;
  margin-top: 10px;
}
.van-cell {
  padding: 10px 0;
  border-bottom: 1px solid #f0f0f0;
}
.van-cell__right-icon {
  transform: rotate(90deg);
}
.btn {
  font-size: 16px;
  text-align: center;
  width: 100%;
  background-color: #fe0000;
  padding: 15px 0;
  margin-top: 50px;
  border-radius: 5px;
  color: white;
}

.btn.no {
  font-size: 16px;
  text-align: center;
  width: 100%;
  background-color: white;
  padding: 15px 0;
  margin-top: 20px;
  border-radius: 5px;
  color: #999;
}
</style>